//
//  MainData.m
//  Tire
//
//  Created by 王奎卿 on 2017/3/22.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "MainData.h"
#import <AFNetworking.h>

static MainData *data = nil;
@implementation MainData

+ (instancetype)shardData
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        data = [[MainData alloc]init];
    });
    return data;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
    if (!data)
    {
        data = [super allocWithZone:zone];
    }
    return data;
}

- (id)copy
{
    return self;
}

- (id)mutableCopy
{
    return self;
}

- (void)getImageData
{
    NSString *str = @"http://lscy4.caeac.com.cn/api/home_update.php?appkey=1138&time=1433337484";
    
    AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]init];
    
    manager.requestSerializer = [[AFJSONRequestSerializer alloc]init];
    
    [manager GET:str parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dic = (NSDictionary *)responseObject;
        
//        NSLog(@"---- %@",dic);
        
        [[NSNotificationCenter defaultCenter]postNotificationName:@"headimg" object:dic];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
}

@end
